import { SET_ROUTES, SET_SIDEBAR_ROUTERS, GENERATE_ROUTES } from "../constant";
const initialState = {
    routes: [],
    sidebarRouters: [],
    leafRouters: [],
  };
  
  const permissionReducer = (state = initialState, action) => {
    const { type, data } = action;
    switch (type) {
      case SET_ROUTES:
        return {
          ...state,
          routes: data.routes,
        };
      case SET_SIDEBAR_ROUTERS:
        return {
          ...state,
          sidebarRouters: data.sidebarRouters,
        };
      case GENERATE_ROUTES:
        return {
          ...state,
          routes: data.routes,
          sidebarRouters: data.sidebarRouters,
          leafRouters: data.leafRouters,
        };
      default:
        return state;
    }
  };


export default permissionReducer;